home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CICA Windows Explosion!
/
The CICA Windows Explosion! - Disc 2.iso
/
programr
/
t-bcinfo.zip
/
TI651.ZIP
/
TI651.ASC
Wrap
Text File
|
1992-02-25
|
1KB
|
67 lines
PRODUCT : C++ NUMBER : 651
VERSION : All
OS : PC DOS
DATE : February 25, 1992 PAGE : 1/1
TITLE : Initializing Static Class Members of Type Class
/* IMPORTANT! When testing static member initialization, you must
declare an instance of the class in a main function; otherwise, the
linker has no reference which it must try to resolve, and the
undefined symbol error will not be seen--thus you won't know that
your initialization was in error.
*/
//declare a class
class First {
public:
int count;
First() {} //must have callable constructor
};
//declare class containing static member of class First
class Second {
public:
static First fVar;
};
//initialize static member of class Second
First Second::fVar = First(); //initialize with explicit call to ctor
int main(void)
{
Second *sVarA = new Second;
delete sVarA;
return 0;
}